// pages/order/order.js
var utils = require('../../utils/util.js')
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		array: [{
			id:1,
			name:"店铺"
		},{
			id:2,
			name:"楼层"
		}],
		index:0

	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		var that = this;
		var data = new Date;
		console.log(utils.formatDate1(data))
		that.setData({
			startdata: utils.formatDate1(data),
			enddata: utils.formatDate1(data)
		})
		that.orderlistTap();
	},
	//选择是店铺和楼层
	bindPickerChange: function (e) {
		var that=this;
		this.setData({
			index: e.detail.value
		})
		that.orderlistTap();
	},
	//开始日期
	startDateChange:function(e){
		var that=this;
		this.setData({
			startdata: e.detail.value
		})
		that.orderlistTap();
	},
	//结束日期
	endDateChange:function(e){
		var that=this;
		this.setData({
			enddata: e.detail.value
		})
		that.orderlistTap();
	},
	//订单列表
	oNOrderDetillistTap: function (e) {
		wx.navigateTo({
			url: '../dministratorsOrderList/dministratorsOrderList?be_id=' + e.currentTarget.dataset.id + "&type=" + this.data.array[this.data.index].id + "&start_time=" + this.data.startdata + "&end_time=" + this.data.enddata,
			success: function (res) { },
			fail: function (res) { },
			complete: function (res) { },
		})
	},

	orderlistTap:function(e){
		var that=this;
		console.log(wx.getStorageSync("openid"))
		utils.http("/api/director/order/order_total",{
			type:that.data.array[that.data.index].id,
			start_time: that.data.startdata,
			end_time: that.data.enddata,
			dir_id: wx.getStorageSync("openid").dir_id
		},function(res){
			console.log(res);
			that.setData({

				roderinfo:res.datas
			})
		})
	},

	oNOrderDetilTap:function(e){
		wx.navigateTo({
			url: ''
		})
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	}
})